import React, { createContext, useMemo} from 'react';
import { DataSet } from 'choerodon-ui/pro';
import fromDS from './formDataSet';

const Store = createContext<Partial<{ children: React.ReactElement, FormDataSet:DataSet }>>({});

export default Store;

export const StoreProvider = (props: { children: React.ReactElement; }) => {
    const {children} = props;
    const FormDataSet = useMemo(() => new DataSet(fromDS()), []);
    const value = {
        ...props,
        FormDataSet,
    };
    return (
      <Store.Provider value={value}>
        {children}
      </Store.Provider>
    );
};